import { getAuthZ } from '../../../../public/js/config/config.js';
import { MessageJson } from '../../../../public/js/common/pointentrance.js';
Utils.NameSpace('SN.H5.Account.Wait');
(function (window, document, $) {
    let _query = {};
    $(function () {
        /*JS严格模式*/
        'use strict';
        $('body').attr('data-weui-theme', 'light');
        _query = Utils.ParsingUrl(window.location);
        let _json = MessageJson[_query.type]
        $('#info').text(_json.info);
        $('#icon').addClass(_json.icon);
        $('#content').text(_json.content);
        document.title = _json.title;
        SN.H5.Account.Wait.EncodeUrl();
        $('#colse').on('click', function () {
            wx.closeWindow();
        });
    });

    /*获取缓存中url地址并编码*/
    SN.H5.Account.Wait.EncodeUrl = function () {
        let wxurl = Utils.GetSessionStorage('url');
        let stateId = Utils.GetQueryString('state');
        $('#btnRetry').attr('href', Utils.CompleteUrl({ wxid: getAuthZ(stateId, "id"), url: wxurl, sid: stateId }));

        $.ajax({
            "url": Utils.CurDomain.AccountUrl + `/mpaccounts/register/${Utils.GetQueryString('state')}/${_query.openId}`, //获取code关联用户的JWT信息
            "type": 'GET',
            "success": function (res) {
                //if (Utils.IsNotNull(res)) {
                //    $('#btnPutWaitInfo').css('display', 'block')
                //} else {
                    $('#btnPutWaitInfo').css('display', 'none')
                //}
            },
            "error": Utils.AjaxError
        });

        //跳转修改页面
        $('#btnPutWaitInfo').on('click', function () {
            window.location.href = `../../../html/account/register.html?v=${Utils.GetTime()}&state=${Utils.GetQueryString('state')}&openId=${_query.openId}`;
        });
    }

})(window, document, jQuery);
